<?php
		
		$id=$_GET['id']; //string nha
		
		$db=new db;
		$db->connect();
		$id=mysql_real_escape_string($id);
		//-------------------------- GET TRUYEN ----------------
		$db->query("select * from anime_tag2 where alias='".$id."'");
		if($db->num_rows()>0){
		$r1=$db->fetchOne();
		$data['tag']=$r1;
		$cache=new Cache;
		$sql ="select * from anime_tag2_fk where tag_id=".$r1['id']." order by anime_id desc";
		$db->query($sql);
		$r1=$db->fetchAll();
		$anime=cache_get_anime($r1[0]['anime_id']);
		$data['anime']=$anime;
		
			
		foreach($r1 as $row){
			$row['fansub']=cache_get_fansub($row['fansub_id']);
			$row['ep']=cache_get_ep($row['ep_id']);
			$data['ep'][]=$row;
		}
		//Ta co ep_id,anime_id
		  //LAY RA ANIME INFO,EP_INFO
		/*  echo "<pre>";
		  print_r($data);
		  echo "</pre>";*/
		}else{ //End of if
		//Khong co trong db
		$r1['name']=$_GET['id'];
		$r1['alias']=khongdau($_GET['id']);
		$data['tag']=$r1;
		
		}

	
	
			
			$data1[title]=web_title($id."| Kết quả tìm kiếm | Anime24h.vn - Xem Anime Online");
			$data1['mota']="Kết quả tìm kiêm từ khóa ".$id;
			$data1['keyword']=$id;
			loadview('template/header',$data1);
			loadview("truyen/tag2",$data);
			
			
